package com.ys.web.hjzf.mapper;

import com.ys.base.BaseDao;
import com.ys.web.mobao.model.po.BindCard;
import com.ys.web.pay.model.vo.UserBank;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface HjzfMapper extends BaseDao {
    @Select("select count(card_no) from user_bank_hjzf where card_no=#{cardNo}")
    int getUserBankCheckCardNo(String cardNo);

    @Insert("insert into user_bank_hjzf(user_id,mobile,user_name,id_card_num,card_no,bank_name,card_token,out_trade_no,bank_type,linkId,cardType,bank_code)" +
            "values(#{userId},#{mobile},#{userName},#{idCardNum},#{cardNo},#{bankName},#{cardToken},#{requestId},#{bankType},#{linkId},#{cardType},#{bankCode})")
    int saveUserBank(BindCard bindCard);

    @Delete("delete from user_bank_hjzf where user_id=#{uid} and card_token=#{cardToken}")
    int delUserBankByCardToken(@Param("uid")long uid, @Param("cardToken") String cardToken);

    @Select("select a.*,b.bank_url_img,ifnull(b.color,'#DC143C') bankColor, b.bank_name bankName from user_bank_hjzf a left join s_sys_bank_mb b on a.bank_code = b.bank_code where user_id= #{uid}")
    List<UserBank> getUserBankByUserId(@Param("uid")long uid);

    @Update("update user_bank_hjzf set linkId = #{linkId},bank_code = #{bankCode} where user_id = #{userId} and card_token=#{cardToken}")
    int updateUserBank(BindCard bindCard);
}
